home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / QUI / UTI / Premier Plug-In Kit 1.0.cpt / Premier Plug-In Kit 1.0 / MPW Examples / .c / Wipe.c < prev    next >
Text File  |  1992-03-04  |  3KB  |  103 lines

  1. //———————————————————————————————————————————————
  2. //
  3. //    ©1991 Adobe Systems Inc.
  4. //    written by Randy Ubillos
  5. //
  6. //———————————————————————————————————————————————
  7.  
  8. // This is a general purpose routine which can be used to create any
  9. // type of effect where the effect shape can be described in a region.
  10. // Simply replace your region generator between the OpenRgn() and
  11. // CloseRgn() calls, and the framework will handle the rest...
  12.  
  13. // Load in your Mac headers here
  14. #pragma load "headers.d"
  15.  
  16. #include "Interface-Effect.h"
  17.  
  18. //———————————————————————————————————————————————
  19. // Perform the effect
  20.  
  21. pascal short xEffect(short selector, EffectHandle theData)
  22. {
  23.     short                result = 0,width,height,spot,hpart,vpart;
  24.     Rect                fullbox,partbox;
  25.     RgnHandle            rgn1,rgn2;
  26.  
  27.     switch (selector) {
  28.         case esExecute:
  29.             rgn1 = NewRgn();                                                    // make 2 regions
  30.             rgn2 = NewRgn();
  31.             fullbox = partbox = ((GrafPtr)(*theData)->destination)->portRect;    // get the bounds
  32.             width = fullbox.right - fullbox.left;                                // calc width
  33.             height = fullbox.bottom - fullbox.top;                                // calc height
  34.             spot = (*theData)->part * (height+width) / (*theData)->total;        // what percentage?
  35.             hpart = (*theData)->part * width / (*theData)->total;                // horiz percent
  36.             vpart = (*theData)->part * height / (*theData)->total;                // vert percent
  37.  
  38.             OpenRgn();                                                // make a region
  39.                                                                     // outline it's shape here
  40.             switch ((*theData)->arrowFlags) {
  41.                 case bitUpperRight:
  42.                     MoveTo(fullbox.right,fullbox.top);
  43.                     LineTo(fullbox.right-spot,fullbox.top);
  44.                     LineTo(fullbox.right,fullbox.top+spot);
  45.                     LineTo(fullbox.right,fullbox.top);
  46.                     break;
  47.                 case bitLowerRight:
  48.                     MoveTo(fullbox.right,fullbox.bottom);
  49.                     LineTo(fullbox.right-spot,fullbox.bottom);
  50.                     LineTo(fullbox.right,fullbox.bottom-spot);
  51.                     LineTo(fullbox.right,fullbox.bottom);
  52.                     break;
  53.                 case bitLowerLeft:
  54.                     MoveTo(fullbox.left,fullbox.bottom);
  55.                     LineTo(fullbox.left+spot,fullbox.bottom);
  56.                     LineTo(fullbox.left,fullbox.bottom-spot);
  57.                     LineTo(fullbox.left,fullbox.bottom);
  58.                     break;
  59.                 case bitUpperLeft:
  60.                     MoveTo(fullbox.left,fullbox.top);
  61.                     LineTo(fullbox.left+spot,fullbox.top);
  62.                     LineTo(fullbox.left,fullbox.top+spot);
  63.                     LineTo(fullbox.left,fullbox.top);
  64.                     break;
  65.                 case bitTop:
  66.                     partbox.bottom = partbox.top + vpart;
  67.                     FrameRect(&partbox);
  68.                     break;
  69.                 case bitRight:
  70.                     partbox.left = partbox.right - hpart;
  71.                     FrameRect(&partbox);
  72.                     break;
  73.                 case bitBottom:
  74.                     partbox.top = partbox.bottom - vpart;
  75.                     FrameRect(&partbox);
  76.                     break;
  77.                 default:
  78.                     partbox.right = partbox.left + hpart;
  79.                     FrameRect(&partbox);
  80.                     break;
  81.             }
  82.  
  83.             CloseRgn(rgn1);                                                    // close the region
  84.             
  85.             RectRgn(rgn2,&fullbox);
  86.             SectRgn(rgn2,rgn1,rgn1);                                        // limit to bounds
  87.             DiffRgn(rgn2,rgn1,rgn2);                                        // find opposite rgn
  88.             CopyBits((BitMap*)&(*theData)->source1->portPixMap,                // copy useful part of
  89.                         (BitMap*)&(*theData)->destination->portPixMap,        // src 2
  90.                                                     &fullbox,&fullbox,srcCopy,rgn2);
  91.             CopyBits((BitMap*)&(*theData)->source2->portPixMap,                // copy useful part of
  92.                         (BitMap*)&(*theData)->destination->portPixMap,        // src 1
  93.                                                     &fullbox,&fullbox,srcCopy,rgn1);
  94.             DisposeRgn(rgn1);
  95.             DisposeRgn(rgn2);                                                // kill the regions
  96.             break;
  97.         case esSetup:                                // we don't do any setup
  98.             break;
  99.     }
  100.     return(result);
  101. }
  102.  
  103.